* Replication do file for Rune Stubager, 'How are social groups linked to the vote? Social group perceptions and party choice', British Journal of Political Science

* This file replicates the main observational analyses of the paper 

net install grc1leg

* Load data
use ".../social_groups_vote_obs_data.dta", clear

* Analyses

* Figure 1

eststo fig11: mlogit party3 i.generat i.gender i.egppar i.educ i.egpclass i.hhkat ib5.q2 c.vurd* if q2 != 2, b(5)
margins, at(vurd1=(-.87 .52)) contrast(atcontrast(r))
margins, at(vurd1=(-3 (.5) 1.5))
marginsplot, title("") saving(sympwc, replace) ytitle("") yscale(r(0 .5)) ylab(0 (.1) .8) xtitle("Working class evaluation") xline(-.87) xline(.52) plot3opts(msymbol(X) mcolor(black) lcolor(black) lpattern(longdash)) ci3opts(color(black)) plot5opts(msymbol(S) mcolor(gs8) lpattern(vshortdash)) ci5opts(color(gs8))

eststo fig12: mlogit party3 i.generat i.gender i.egppar i.educ i.egpclass i.hhkat ib2.q2 c.vurd* if q2 != 4, b(5)
margins, at(vurd2=(-.52 .76)) contrast(atcontrast(r))
margins, at(vurd2=(-3 (.5) 1.5)) 
marginsplot, title("") saving(sympmc, replace) ytitle("") yscale(r(0 .5)) ylab(0 (.1) .8) xtitle("Middle class evaluation") xline(-.52) xline(.76) plot3opts(msymbol(X) mcolor(black) lcolor(black) lpattern(longdash)) ci3opts(color(black)) plot5opts(msymbol(S) mcolor(gs8) lpattern(vshortdash)) ci5opts(color(gs8))

eststo fig13: mlogit party3 i.generat i.gender i.egppar i.educ i.egpclass i.hhkat ib2.q2 c.vurd* if q2 != 5, b(5)
margins, at(vurd3=(-.64 .79)) contrast(atcontrast(r))
margins, at(vurd3=(-3 (.5) 2)) 
marginsplot, title("") saving(sympumc, replace) ytitle("") yscale(r(0 .5)) ylab(0 (.1) .8) xtitle("Upper middle class evaluation") legend(rows(1) order(6 "Left Soc" 7 "SD" 8 "Soc Lib" 9 "DPP" 10 "ER" )) xline(-.64) xline(.79) plot3opts(msymbol(X) mcolor(black) lcolor(black) lpattern(longdash)) ci3opts(color(black)) plot5opts(msymbol(S) mcolor(gs8) lpattern(vshortdash)) ci5opts(color(gs8))

eststo fig14: mlogit party3 i.generat i.gender i.egppar i.educ i.egpclass i.hhkat ib2.q2 c.vurd* if q2alt != 6, b(5)
margins, at(vurd4=(-.86 .75)) contrast(atcontrast(r))
margins, at(vurd4=(-2 (.5) 3))
marginsplot, title("") saving(sympuc, replace) ytitle("") yscale(r(0 .5)) ylab(0 (.1) .8) xtitle("Upper class evaluation") legend(rows(1) order(6 "Left Soc" 7 "SD" 8 "Soc Lib" 9 "DPP" 10 "ER" )) xline(-.86) xline(.75) plot3opts(msymbol(X) mcolor(black) lcolor(black) lpattern(longdash)) ci3opts(color(black)) plot5opts(msymbol(S) mcolor(gs8) lpattern(vshortdash)) ci5opts(color(gs8))

grc1leg sympwc.gph sympmc.gph sympumc.gph sympuc.gph, imargin(0 0 0 0) legendfrom(sympuc.gph) 

* Figure 2

tab party3, gen(party3_)

reshape long party3_ kaempak kaempmk kaempomk kaempok, i(caseid) j(parti)

cmset caseid parti

qui cmclogit party3_ c.kaempak c.kaempak#c.vurd1 if q2 !=2, casevars(i.generat i.gender i.educ i.egpclass i.hhkat i.q2 c.vurd1 c.vurd2 c.vurd3 c.vurd4) base(5)
margins, at(vurd1=(-3 (.5) 1.5) kaempak=(.4 .75)) outcome(1) alternative(1) 
marginsplot, title("Left Socialists") yscale(r(0 .85)) ylab(0 (.1) .8) xline(-.88) xline(.52) ytitle("") xtitle("WC evaluations") legend(order(3 "Party percept at 25th pct" 4 "Party percept at 75th pct")) saving(dif1, replace)
margins, at(vurd1=(-3 (.5) 1.5) kaempak=(.4 .7)) outcome(2) alternative(2) 
marginsplot, title("Social Democrats") yscale(r(0 .85)) ylab(0 (.1) .8) xline(-.88) xline(.52) ytitle("") xtitle("WC evaluations") legend(order(3 "Party percept at 25th pct" 4 "Party percept at 75th pct")) saving(dif2, replace)
margins, at(vurd1=(-3 (.5) 1.5) kaempak=(.2 .5)) outcome(5) alternative(5) 
marginsplot, title("Economic Right") yscale(r(0 .85)) ylab(0 (.1) .8) xline(-.88) xline(.52) ytitle("") xtitle("WC evaluations") legend(order(3 "Party agency at 25th pct" 4 "Party agency at 75th pct") size(small)) saving(dif5, replace)

grc1leg dif1.gph dif2.gph dif5.gph , title("The Working Class", size(medium)) imargin(0 0 0 0) cols(1) saving(komb1, replace)

qui cmclogit party3_ c.kaempok c.kaempok#c.vurd4 if q2alt !=6, casevars(i.generat i.gender i.educ i.egpclass i.hhkat i.q2 c.vurd1 c.vurd2 c.vurd3 c.vurd4) base(5)
margins, at(vurd4=(-2 (.5) 2) kaempok=(.1 .5)) outcome(1) alternative(1) 
marginsplot, title("Left Socialists") yscale(r(0 .85)) ylab(0 (.1) .8) xline(-.86) xline(.75) ytitle("") xtitle("UC evaluations") legend(order(3 "Party percept at 25th pct" 4 "Party percept at 75th pct")) saving(dif1, replace)
margins, at(vurd4=(-2 (.5) 2) kaempok=(.3 .6)) outcome(2) alternative(2) 
marginsplot, title("Social Democrats") yscale(r(0 .85)) ylab(0 (.1) .8) xline(-.86) xline(.75) ytitle("") xtitle("UC evaluations") legend(order(3 "Party percept at 25th pct" 4 "Party percept at 75th pct")) saving(dif2, replace)
margins, at(vurd4=(-2 (.5) 2) kaempok=(.5 .8)) outcome(5) alternative(5) 
marginsplot, title("Economic Right") yscale(r(0 .85)) ylab(0 (.1) .8) xline(-.86) xline(.75) ytitle("") xtitle("UC evaluations") legend(order(3 "Party agency at 25th pct" 4 "Party agency at 75th pct") size(small)) saving(dif5, replace)

grc1leg dif1.gph dif2.gph dif5.gph,  title("The Upper Class", size(medium)) imargin(0 0 0 0) cols(1) legendfrom(dif5.gph) saving(komb2, replace)

grc1leg komb1.gph komb2.gph, cols(2) legendfrom(komb2.gph)
graph display, ysize(7)

